﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.UI;

namespace HotFix_Project
{
	public class ILHotUpdateLogic : MonoBehaviour
	{
		public GameObject panel;
		public Text lab_title;
		public Text lab_msg;
		public Button btn_ok;
		public Button btn_cancle;

		public void Awake()
		{
			UnityEngine.Debug.Log("!!ILHotUpdateLogic::Awake");
		}

		void Start()
		{
			UnityEngine.Debug.Log("!!ILHotUpdateLogic::Start");
		}

		public void Init()
		{
			InitComponent();
			ShowData();
		}

		public void InitComponent()
		{
			panel = this.gameObject.transform.Find("Panel").gameObject;
			lab_title = this.gameObject.transform.Find("Panel/txt_title").GetComponent<Text>();
			lab_msg = this.gameObject.transform.Find("Panel/txt_msg").GetComponent<Text>();
			btn_ok = this.gameObject.transform.Find("Panel/btn_ok").GetComponent<Button>();
			btn_cancle = this.gameObject.transform.Find("Panel/btn_cancle").GetComponent<Button>();
			btn_ok.onClick.AddListener(OnOkClick);
			btn_cancle.onClick.AddListener(OnCancleClick);
		}

		public void ShowData()
		{
			lab_title.text = "New_Title";
			lab_msg.text = "This is modified by ILHotUpdateLogic!";
		}

		private void OnOkClick()
		{
			Debug.Log("<color=yellow>On OK Click</color>");
			lab_msg.text = "On OK Click!";
		}

		private void OnCancleClick()
		{
			Debug.Log("<color=yellow>On Cancle Click</color>");
			lab_msg.text = "On Cancle Click!";
		}
	}

	public class TestAddMonoBehaviour
	{
		public static void RunTest(GameObject go)
		{
			ILHotUpdateLogic hotUpdateLogic = go.AddComponent<ILHotUpdateLogic>();
			hotUpdateLogic.Init();
		}
	}
}
